import {useGlobalUserStore} from '@/store/userGlobalStore'

export const AuthDiretive = {
    name: 'auth',
    mounted(el, binding) {
        const {permissions} = useGlobalUserStore()
        if (!binding.value) {
            throw "v-auth:value 参数必传"
        }
        if(!permissions || !el) return
        if(permissions.includes("*:*:*")) return
        if(permissions.includes(binding.value)) return
        // 没有权限，移除元素
        const parent = el.parentElement
        parent && parent.removeChild(el)
    }
}